<?php
namespace Mobile\Model;
use Think\Model;
use Common\Model\Movie;
class ScreeningModel extends Model{
    public function setAll($time){
         $model=$this->select();
         foreach($model as $key => $value){
           if(date('m-d',$value['showtime'])==$time){
               $list[$key]=$value['id'];
            }
         }
            return $list;
    }

    public function getAll($id,$mid){
        $arr=$this->field('u.id uid,ps.id sid,u.name uname,u.address uadd,ps.showtime time')->
        table('pre_user u,pre_screening ps')->
        where('ps.user_id=u.id and ps.id='.$id.' and ps.movie_id='.$mid)->select();
        foreach($arr as $key =>$value){
            $arr[$key]['time']=date('H:i',$value['time']);
        }
        return $arr[0];
    }

    public function arAll($uid,$id,$mid){
        $arr=$this->field('ps.id sid,u.name uname,u.address uadd,ps.showtime time,m.name mname,m.long ml,m.language lg,ps.price p,r.name rname,r.id rid')->
        table('pre_user u,pre_screening ps,pre_movie m,pre_room r')->
        where('u.id='.$uid.' and ps.movie_id='.$mid.' and ps.user_id=u.id and r.user_id=u.id and ps.id='.$id)->select();
        foreach($arr as $key =>$value){
            $arr[$key]['lg']=Movie::languageAlias($value['lg']);
            $arr[$key]['ml']=$value['time']+($value['ml']*60);
        }
        return $arr[0];
    }
}



?>